<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<c:if test="${canAddOrUpdate eq true}">
<div class="top-right-btn">
	<a href="exam.pt">Create New Exam</a>
</div>
</c:if>

<br/>

<form:form action="exams.pt" method="POST">
	<input type="hidden" name="action_value" id="idActionValue" value="" />
	
	<form:errors path="*" cssClass="error-message"/>
	
	<table class="input-table">
	<tbody>
		<tr>
			<td>Course</td>
			<td>
				<form:select path="course" onchange="doSubmit('action_course_select')" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${courses}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
			<td>Semester</td>
			<td>
				<form:select path="subCourse" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${semesters}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td>Exam Type</td>
			<td>
				<form:select path="examType" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${examTypes}"/>
				</form:select>
			</td>
			<td width="40%">
				<input type="button" value="Show" name="action_btn_show" onclick="doSubmit('action_show')"/>
			</td>
		</tr>
	</tbody>
	</table>
</form:form>

<table class="list-results-table">
	<tbody>
		<tr>
			<th>Name</th>
			<th>Exam ID</th>
			<th>Date of Exam</th>
			<th>Exam Type</th>
			<th width="10%">Created Date</th>
			<th width="15%">Last Updated Date</th>
		</tr>
		
		<c:forEach items="${exams}" var="exam">
		<tr>
			<td><a href="exam.pt?id=<c:out value="${exam.id}"/>"><c:out value="${exam.name}"/></a></td>
			<td><c:out value="${exam.examId}"/></td>
			<td>
				<fmt:formatDate value="${exam.examDate}" pattern="dd-MM-yyyy"/>
			</tD>
			<td><c:out value="${examTypes[exam.examType]}"/></tD>
			<td>
				<fmt:formatDate value="${exam.createdDate}" pattern="dd-MM-yyyy"/>
			</td>
			<td>
				<fmt:formatDate value="${department.lastUpdatedDate}" pattern="dd-MM-yyyy"/>
			</td>
		</tr>
		</c:forEach>
	</tbody>
</table>